package org.dromara.system.api.feign.fallback;

import cn.hutool.http.HttpStatus;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
import org.dromara.system.api.domain.bo.RemoteTaskAssigneeBo;
import org.dromara.system.api.domain.vo.RemoteTaskAssigneeVo;
import org.dromara.system.api.feign.SystemTaskAssigneeClient;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author: zhou shuai
 * @date: 2025/2/21 23:06
 * @version: v1
 */
@Slf4j
@Component
public class SystemTaskAssigneeFallBack implements FallbackFactory<SystemTaskAssigneeClient> {
    @Override
    public SystemTaskAssigneeClient create(Throwable throwable) {
        log.error("SystemTaskAssigneeFallBack, cause:{}", throwable.getMessage());
        return new SystemTaskAssigneeClient() {
            @Override
            public R<RemoteTaskAssigneeVo> selectRolesByTaskAssigneeList(RemoteTaskAssigneeBo taskQuery) {
                return R.fail(HttpStatus.HTTP_BAD_METHOD, throwable.getLocalizedMessage());
            }

            @Override
            public R<RemoteTaskAssigneeVo> selectPostsByTaskAssigneeList(RemoteTaskAssigneeBo taskQuery) {
                return R.fail(HttpStatus.HTTP_BAD_METHOD, throwable.getLocalizedMessage());
            }

            @Override
            public R<RemoteTaskAssigneeVo> selectDeptsByTaskAssigneeList(RemoteTaskAssigneeBo taskQuery) {
                return R.fail(HttpStatus.HTTP_BAD_METHOD, throwable.getLocalizedMessage());
            }

            @Override
            public R<RemoteTaskAssigneeVo> selectUsersByTaskAssigneeList(RemoteTaskAssigneeBo taskQuery) {
                return R.fail(HttpStatus.HTTP_BAD_METHOD, throwable.getLocalizedMessage());
            }
        };
    }
}
